<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$setting=$this->plugin_setting('page');
if($_RQ['op']=='main'){
	if($setting['closed_qrcode']){
		exi('没有开启推广二维码','error','jy_xiangqin/fuwu.index/');
	}
	$setting['tcommission']=$setting['tcommission']?$setting['tcommission']:'佣金';
	if($setting['become_child']==1){
		$setting['t1']='如果您的好友下单，';
	}else{
		$setting['t1']='如果您的好友下单并付款，';
	}
	$setting['torder']=$setting['torder']?$setting['torder']:'分销订单';
	$setting['tmydown']=$setting['tmydown']?$setting['tmydown']:'我的商户';
	$setting['twithdraw']=$setting['twithdraw']?$setting['twithdraw']:'提现';	
	$return['setting']=$setting;
	$zhan_id=$this->getcolumn('member',array('mid'=>$_SESSION['uid']),'id');
	$url=custom_url('jy_merch/register/get/zhan_id='.$zhan_id.'&fromuser='.$_SESSION['uid'],true);
	$return['qrcode']=cfc('tools')->createqrcode($url,'250',true);
	$return['qrcode']=tomedia($return['qrcode']);
	$image=ROOT_AT.'images/jy_merch/'.$_SESSION['uniacid'].'/zhan_id'.$zhan_id.'.jpg';
	if(!file_exists($image)){
		$url='/jy_merch/register/index?zhan_id='.$zhan_id.'&fromuser='.$_SESSION['uid'];
		$wxapp=pdo_get('core_account_wxapp',array('id'=>$_SESSION['wxapp_id'],'uniacid'=>$_SESSION['uniacid']));
		$res=model('core/wxapp')->appcode($url,$wxapp['appid'],$wxapp['appsecret'],200);
		$path=ROOT_AT.'images/jy_merch/'.$_SESSION['uniacid'];
		if(!file_exists($path)){
				mkdir($path,0700, true);
		}
		file_put_contents($path.'/zhan_id'.$zhan_id.'.jpg',$res);
	}
	$return['appcode'] = 'images/jy_merch/'.$_SESSION['uniacid'].'/zhan_id'.$zhan_id.'.jpg';
	exi($return);
}

?>